import React, { useState } from 'react';
import { Button, Overlay } from 'react-vant';
import { editIntegral } from '../../../../api/userinfo';
export default (props) => {
  const [visible, setVisible] = useState(false);
  const { name, price, img, integral,uid,coid,type} = props.userIntegral
  const editer = async ()=>{
    setVisible(false)
    let res = await editIntegral({name,price,img,integral,uid,coid,type})
  }
  return (
    <>
      <Button type="primary" onClick={() => setVisible(true)}>
        兑换
      </Button>
      <Overlay visible={visible}
        style={{
          height: '100%',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
        }}>
        <div style={{ width: 300, height: 200, backgroundColor: '#fff', borderRadius: 4, borderRadius: '30rem', }}>
          <p style={{ margin: 50, fontWeight: 'bold' }}>
            兑换成功
          </p>
          <button style={{ width: 220, height: 50, backgroundColor: 'red', borderRadius: 24 }} onClick={ ()=>{editer()}}  >确认</button>
        </div>
      </Overlay>
    </>
  );
};